package com.aier.controller.form;

import com.aier.bean.common.CommonResult;
import com.aier.service.form.FormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 表单controller
 */

@Controller
@CrossOrigin
@RequestMapping("/form")
public class FormController {

    @Autowired
    private FormService formService;

    @RequestMapping("/get_structure")
    @ResponseBody
    public CommonResult getObjectFieldAndType(@RequestBody Map<String,String> map) throws ClassNotFoundException {
        String classPath = map.get("classPath");
        List<Map<String, List<String>>> fieldMapList = formService.getObjectFieldAndType(classPath);
        return CommonResult.success(fieldMapList);
    }


}
